package com.isunland.managesystem.adapter;

import android.support.annotation.NonNull;
import android.view.View;
import android.widget.TextView;
import butterknife.BindView;
import com.isunland.managesystem.R;
import com.isunland.managesystem.base.BaseButterKnifeAdapter;
import com.isunland.managesystem.base.BaseVolleyActivity;
import com.isunland.managesystem.entity.CustomerMainOriginal.rCustomerMain;
import com.isunland.managesystem.utils.MyStringUtil;
import com.isunland.managesystem.utils.MyUtils;
import java.util.ArrayList;

/**
 * 对象功能:
 * 开发公司: 北京信普达系统工程有限公司
 * 开发人员: wangyanan
 * 创建时间: 2017/4/5 15:01
 */

public class CustomerAdapter extends BaseButterKnifeAdapter<rCustomerMain> {

  @SuppressWarnings("unused")
  public CustomerAdapter(BaseVolleyActivity context, ArrayList<rCustomerMain> objects) {
    super(context, objects);
  }

  @Override protected int setLayoutId() {
    return R.layout.adapter_customer;
  }

  @NonNull @Override protected BaseViewHolder initHolder(View convertView) {
    return new ViewHolder(convertView);
  }

  @Override protected void initView(rCustomerMain item, BaseViewHolder baseHolder, int position) {
    ViewHolder holder = (ViewHolder) baseHolder;
    holder.tvTitle.setText(item.getCustomerName());
    holder.tvContent1.setText(item.getCustomerStatusName());
    holder.tvTitleRight.setText(context.getString(R.string.customerContactWithHolder,
        item.getContactManNames() == null ? "" : item.getContactManNames()));
    holder.tvContent1Right.setText(context.getString(R.string.contactPhoneWithHolder,
        item.getContactNum() == null ? "" : item.getContactNum()));
    holder.tvBottom.setText(context.getString(R.string.ourPrincipalWithHolder,
        item.getChargeManNames() == null ? "" : item.getChargeManNames()));
    MyUtils.switchShadowStutus(context, holder.tvBottomRight, item.getDataStatus());
    //审核通过时使用统一颜色
    //if (MyStringUtil.equals(DataStatus.PUBLIS, item.getDataStatus())) {
    //  holder.tvBottomRight.setTextColor(holder.tvBottom.getCurrentTextColor());
    //}

    holder.ivLogo.setText(MyStringUtil.substring(item.getDistrictDesc(), 0, 2));
    //noinspection deprecation
    //holder.ivLogo.setTextColor(context.getResources()
    //    .getColor(!MyStringUtil.equals(DataStatus.PUBLIS, item.getDataStatus()) ? R.color.grey
    //        : R.color.primary));
  }

  protected class ViewHolder extends BaseViewHolder {
    @BindView(R.id.iv_logo) TextView ivLogo;
    @BindView(R.id.tv_title) TextView tvTitle;
    @BindView(R.id.tv_title_right) TextView tvTitleRight;
    @BindView(R.id.tv_content1) TextView tvContent1;
    @BindView(R.id.tv_content1_right) TextView tvContent1Right;
    @BindView(R.id.tv_bottom) TextView tvBottom;
    @BindView(R.id.tv_bottom_right) TextView tvBottomRight;

    ViewHolder(View view) {
      super(view);
    }
  }
}
